<extend name="Public/base"/>

<block name="body">
    <div class="main-title">
        <h2>
            关联活动与商品
        </h2>
    </div>
    <div class="tab-wrap">
        <div class="tab-content">
            <form id="form" action="{:U('')}" method="post" class="form-horizontal">
                <!--TAB S-->
                <div class="form-item cf">
                    <label class="item-label">选择活动</label>
                    <div class="controls">
                        <select name="seckillId" class="select input-large">
                            <volist name="data.list" id="vo">
                                <option value="{$vo.id}">{$vo.name}</option>
                            </volist>
                        </select>
                    </div>
                </div>
                <div class="form-item cf">
                    <label class="item-label">关联商品<span class="check-tips"><a href='#' class='btn btn-primary' id="addspec">添加新商品</a></span></label>
                    <div class="controls">
                        <div style="border: #000 1px solid;width: 60%" class='data-table table-striped'>
                            <table >
                                <thead><tr>
                                        <th>商品</th>
                                        <th>活动价格</th>
                                        <th>活动库存</th>
                                        <th>单用户限购量</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody id="tbodyspec">
                                    <tr>
                                        <td>选择商品
                                            <select data-form="select2" style="height: 30px; width:200px;" name="specid[]" >
                                                <option value="0">请选择...</option>
                                                <volist name="data.prolist" id="pl">
                                                    <option value={$pl.specid},{$pl.pid}>{$pl.pname}({$pl.specname})</option>
                                                </volist>
                                            </select>
                                        </td>
                                        <td><input type="text" class="text input-small" name="price[]" value="" placeholder="输入活动价格" ></td>
                                        <td><input type="text" class="text input-small" name="store[]" value="" placeholder="输入活动库存" ></td>
                                        <td><input type="text" class="text input-small" name="maxcnt[]" value="" placeholder="输入活动数量" ></td>
                                        <td></td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                <!--tab e-->
                <div class="form-item cf">
                    <!--<button class="btn submit-btn ajax-post" type="submit" target-form="form-horizontal" autocomplete="off">发布商品</button>-->
                    <button class="btn submit-btn " type="submit" target-form="form-horizontal" autocomplete="off">发布商品</button>
                    <button class="btn btn-return" onclick="javascript:history.back(-1);
                    return false;">返 回</button>
                </div>
            </form>
        </div>
    </div>
</block>

<block name="script">
    <script type="text/javascript">
        $(document).ready(function () {
            $(".tab-nav > li").click(function () {
                var tab = $(this).data('tab');
                $(".tab-nav > li").removeClass('current');
                $(this).addClass('current');
                $(".tab-pane").removeClass('in');
                var obj = $('#' + tab);
                obj.addClass('in');
            });
            $('#addspec').click(function () {
                var html = '<tr><td>选择商品 <select data-form="select2" style="height: 30px; width:200px;" name="specid[]" ><option value="0">请选择...</option><volist name="data.prolist" id="pl"><option value={$pl.specid},{$pl.pid}>{$pl.pname}({$pl.specname})</option></volist></select></td><td><input type="text" class="text input-small" name="price[]" value="" placeholder="输入活动价格" ></td><td><input type="text" class="text input-small" name="store[]" value="" placeholder="输入活动库存" ></td><td><input type="text" class="text input-small" name="maxcnt[]" value="" placeholder="输入限购数量" ></td><td><a href="#" class="btn btn-primary trdelspec">删除</a></td></tr> ';
                $('#tbodyspec').append(html);
                $('[data-form=select2]').select2();
                $('.trdelspec').bind("click", function () {
                    $(this).parent().parent().remove();
                });
            });
        });
        highlight_subnav('{:U('Seckill/proindex')}');
    </script>
</block>